// 将 base64 转换为 Blob
function base64ToBlob(base64: any) {
  var arr = base64.split(','),
    mime = arr[0].match(/:(.\*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n)
  while (n--) {
    u8arr[n] = bstr.charCodeAt(n)
  }
  return new Blob([u8arr], {
    type: mime
  })
}

//将blob转换为file
function blobToFile(blob: any, fileName: any) {
  return new File([blob], fileName)
}

function base64toFile(base64Str:any, fileName:any) {
  let arr = base64Str.split(',');
  let mime = arr[0].match(/:(.*?);/)[1];
  let bstr = atob(arr[1]);
  let n = bstr.length;
  let u8arr = new Uint8Array(n);
  while (n--) {
  u8arr[n] = bstr.charCodeAt(n);
  }
  return new File([u8arr], fileName, { type: mime })
  }
//调用
export { base64ToBlob, blobToFile,base64toFile }
